import os
from datetime import timedelta

class Config:
    # 基本配置
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard_to_guess_string'
    
    # MongoDB 配置
    MONGO_URI = os.environ.get('MONGO_URI') or 'mongodb://localhost:27017/toolbox'
    
    # 文件上传配置
    MAX_CONTENT_LENGTH = 16 * 1024 * 1024  # 16MB 最大上传大小
    UPLOAD_FOLDER = 'app/static/uploads'
    ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'}
    
    # Flask-Login 配置
    REMEMBER_COOKIE_DURATION = timedelta(days=30)
    
    # 应用特定配置
    TOOLS_PER_PAGE = 12  # 每页显示的工具数量
    
    
class DevelopmentConfig(Config):
    DEBUG = True


class TestingConfig(Config):
    TESTING = True
    MONGO_URI = 'mongodb://localhost:27017/toolbox_test'
    WTF_CSRF_ENABLED = False


class ProductionConfig(Config):
    DEBUG = False
    # 生产环境使用更强的密钥
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'super_hard_to_guess_production_key'


config = {
    'development': DevelopmentConfig,
    'testing': TestingConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
} 